Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 7, 2025

Supports code completion, code inspection for the class package and class name where the staticProperty is called.

  • For "@packageName.ClassName@", it searches for the package name from the libraries in the project, and searches for child packages and files separated by dots to provide suggestions.
  • For "@packageName.ClassName@", search the dot-separated package name hierarchically and check that an existing package name is being used.

@xterao xterao added this to the 0.7.0 Release milestone May 7, 2025
@xterao xterao added the enhancement New feature or request label May 7, 2025
@xterao xterao changed the title completion static class package Code completion and code inspection for static property call package class names May 7, 2025
@xterao xterao linked an issue May 7, 2025 that may be closed by this pull request
@xterao xterao force-pushed the feature/completion-static-class-package branch from 20008f7 to a50237e Compare May 8, 2025 01:18
@xterao xterao force-pushed the feature/completion-static-class-package branch from a50237e to 1bf5898 Compare May 8, 2025 01:23
@xterao xterao requested a review from Copilot May 8, 2025 01:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements code completion and inspection for static property call package class names. It introduces new collectors for static properties, class package suggestions, and build functions, refactoring existing retrievals of Java classes to use project-based extensions.

  • Added new project extension for retrieving Java classes.
  • Implemented new collectors: StaticPropertyCollector, StaticClassPackageCollector, and StaticBuildFunctionCollector.
  • Refactored static directive handling to use the new collectors.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/kotlin/org/domaframework/doma/intellij/extension/ProjectExtensions.kt Adds a new getJavaClazz function to retrieve PsiClass based on a fully qualified name.
src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt Updates usage of getJavaClazz to use the project extension.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticPropertyCollector.kt Implements a collector for static property completion suggestions.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticDirectiveHandlerCollector.kt Adds an abstract base for static directive handler collectors.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticClassPackageCollector.kt Introduces package collection via package and file lookups for completion suggestions.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt Implements built-in functions collector for SQL directives.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/StaticDirectiveHandlerData.kt Defines data structures for static directive completions.
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/StaticDirectiveHandler.kt Refactors static directive handling to use the new collectors.
src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiStaticElement.kt Updates getRefClazz to use the project-based getJavaClazz.
src/main/kotlin/org/domaframework/doma/intellij/common/FileTypeCheck.kt Adds a helper function for checking if a file is a Java or Kotlin file.
Comments suppressed due to low confidence (2)

src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticClassPackageCollector.kt:67

  • Consider using an equality check (==) instead of contains when matching package names if an exact match is intended, to avoid unintended fuzzy matching.
subPackagesParent = parentPackages?.find { it?.name?.contains(pkg) == true }

src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt:65

  • [nitpick] Multiple DomaFunction instances are defined with the same name 'roundDownTimePart' but different type information. Consider differentiating the function names or adding documentation to clarify their intended usage.
DomaFunction("roundDownTimePart", getJavaLangString(), listOf(getPsiTypeByClassName("java.lang.CharSequence"), getPsiTypeByClassName("java.lang.Char")))

@xterao xterao force-pushed the feature/completion-static-class-package branch from 74320e9 to 44b293d Compare May 8, 2025 01:49
@xterao xterao added the feature label May 8, 2025
@xterao xterao merged commit 53cbaf9 into main May 8, 2025
3 checks passed
@xterao xterao deleted the feature/completion-static-class-package branch May 8, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completion and inspection of class names for static property calls

2 participants